<?php
global $base_dir;
$base_dir='../';

/**** 模块调用*****/
include_once($base_dir."inc/inc_connect.php");		//通用函数包含文件
include_once($base_dir."inc/ClassUpfile.php");		//图片上传类

include_once("index_inc.php");
include_once("func/function.php");
include_once($base_dir."inc/manage.php");			//后台通用包含文件
?>
<?php
if(is_array($_POST))
{
	foreach($_POST as $key => $value)
	{
		$$key=$value;
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统</title>
</head>
<body>
<?php
$t=new Tbl_Act($tbl_name,$tbl_key);		//创建表对象
if(is_array($_POST))
{
	foreach($_POST as $key => $value)
	{
		$t->$key=$value;
	}
	foreach($_GET as $key => $value)
	{
		$t->$key=$value;
	}
	if(isset($t->admin_pwd) && $t->admin_pwd=='')
	{
		unset($t->admin_pwd);
	}
	else
	{
		$t->admin_pwd=md5($t->admin_pwd);
	}
	//上传图片 start
	if(is_array($_FILES['upfile']) && $_FILES['upfile']['name']!='')
	{
		$u=new ClassUpfile($_FILES['upfile']);
		if($filename=$u->upload($base_dir.'upload/'))
		{
			$t->news_img="/upload/$filename";
		}
		else
		{
			echo '图片上传失败';
		}
	}
	//上传图片 end
	switch($t->act)
	{
		case 'save':	//添加
			$t_num=$t->RsCount(array('admin_username,='));
			if($t->mem_pwd=='') {
			  unset($t->mem_pwd);
			} else {
			  $t->mem_pwd=md5($mem_pwd);
			}
			if($t_num==0){
			  if($insertid=$t->Insert()){
			    echo '添加成功...';
			    $url=$url_list;
			  } else {
				echo '添加失败...';
				$url=$url_add;
			  }
			} else {
			  echo "添加失败,有重复数据";
			  $url=$url_add;
			}
			break;
		case 'update':
			if($t->mem_pwd=='')
			{
				unset($t->mem_pwd);
			}
			else
			{
				$t->mem_pwd=md5($mem_pwd);
			}
			if($t_num==0)
			{
				if($insertid=$t->Update())
				{
					echo '修改成功...';
					$url=$url_list;
				}
				else
				{
					echo '修改失败...';
					$url=$url_list;
				}
			}
			else
			{
				echo "修改失败,有重复数据";
				$url=$url_list;
			}
			break;
		case 'del':
			if($t->Del())
			{
				echo '删除成功...';
				$url=$url_list;
			}
			else
			{
				echo '删除失败...';
				$url=$url_list;
			}
		default:
			break;
	}
}
?>
<script language="javascript">
setTimeout("location.href='<?=$url?>'",1500);
</script>
</body>
</html>
<?php
include_once($base_dir."inc/inc_unconnect.php")
?>